﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using MikeKappel.Com.CS.Model;

namespace MikeKappel.Com.CS.Services
{
    // NOTE: If you change the interface name "IService" here, you must also update the reference to "IService" in Web.config.
    [ServiceContract(Name = "DateDifferentialService", Namespace = "http://Services.MichaelKappel.com/2010/02/", SessionMode = SessionMode.Allowed)]
    public interface IDateDifferentialService
    {
        [OperationContract(Name = "DateDifferentialService")]
        DateDifferentialServiceType GetDateDifferential(DateTime firstDate, DateTime secondDate);

        // TODO: Add your service operations here
    }

    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract(Name = "DateDifferential", Namespace = "http://Schemas.MichaelKappel.com/2010/02/")]
    public class DateDifferentialServiceType
    {
        public DateDifferentialServiceType(DateDifferential differential)
        {
            Millennia = differential.Millennia.Value;
            Centuries = differential.Centuries.Value;
            Decades = differential.Decades.Value;
            Years = differential.Years.Value;
            Months = differential.Months.Value;
            Weeks = differential.Weeks.Value;
            Days = differential.Days.Value;
            Days = differential.Days.Value;
            Hours = differential.Hours.Value;
            Minutes = differential.Minutes.Value;
            Seconds = differential.Seconds.Value;
            Milliseconds = differential.Milliseconds.Value;
            Difference = differential.Difference;
            EarlierDate = differential.EarlierDate;
            LaterDate = differential.LaterDate;
        }
        /// <summary>
        /// Millennium part of the difference between dates
        /// </summary>
        [DataMember(Order = 0, Name = "Millennia")]
        public Int32 Millennia { get; private set; }


        /// <summary>
        /// Century part of the difference between dates
        /// </summary>
        [DataMember(Order = 1, Name = "Centuries")]
        public Int32 Centuries { get; private set; }

        /// <summary>
        /// Decade part of the difference between dates
        /// </summary>
        [DataMember(Order = 2, Name = "Decades")]
        public Int32 Decades { get; private set; }

        /// <summary>
        /// Year part of the difference between dates
        /// </summary>
        [DataMember(Order = 3, Name = "Years")]
        public Int32 Years { get; private set; }

        /// <summary>
        /// Month part of the difference between dates
        /// </summary>
        [DataMember(Order = 4, Name = "Months")]
        public Int32 Months { get; private set; }

        /// <summary>
        /// Day part of the difference between dates
        /// </summary>
        [DataMember(Order = 5, Name = "Weeks")]
        public Int32 Weeks { get; private set; }

        /// <summary>
        /// Day part of the difference between dates
        /// </summary>
        [DataMember(Order = 6, Name = "Days")]
        public Int32 Days { get; private set; }

        /// <summary>
        /// Hour part of the difference between dates
        /// </summary>
        [DataMember(Order = 7, Name = "Hours")]
        public Int32 Hours { get; private set; }

        /// <summary>
        /// Minute part of the difference between dates
        /// </summary>
        [DataMember(Order = 8, Name = "Minutes")]
        public Int32 Minutes { get; private set; }

        /// <summary>
        /// Second part of the difference between dates
        /// </summary>
        [DataMember(Order = 9, Name = "Seconds")]
        public Int32 Seconds { get; private set; }

        /// <summary>
        /// Millisecond part of the difference between dates
        /// </summary>
        [DataMember(Order = 10, Name = "Milliseconds")]
        public Int32 Milliseconds { get; private set; }

        /// <summary>
        /// Total difference between dates
        /// </summary>
        [DataMember(Order = 11, Name = "Difference")]
        public TimeSpan Difference { get; private set; }

        /// <summary>
        /// Earlier of the two dates
        /// </summary>
        [DataMember(Order = 12, Name = "EarlierDate")]
        public DateTime EarlierDate { get; private set; }

        /// <summary>
        /// Later of the two dates
        /// </summary>
        [DataMember(Order = 13, Name = "LaterDate")]
        public DateTime LaterDate { get; private set; }
    }
}